package com.eternal.login.shiro;


import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;


/**
 * @Class ShiroCryptographyUtil
 * @Description: Shiro密码学工具
 * @Author Eternal
 * @Version
 * @date 2018/9/15 21:19
 */
public class ShiroCryptographyUtil {
    public static final String SHA1 = "SHA-1";
    public static final String MD5 = "MD5";

    /**
     * <p> MD5密码加密  </p>
     *
     * @param source：加密的字符串
     * @param salt：盐值
     * @param hashIterations：加密的次数
     * @Description: TODO
     * @Author Eternal
     * @Date 2018/9/15 21:23
     */
    public static String encryptMD5(String source, String salt, int hashIterations) {
        ByteSource saltz = ByteSource.Util.bytes(salt);
        SimpleHash hash = new SimpleHash(SHA1, source, salt, hashIterations);
        return hash.toString();
    }

    public static void main(String[] args) {
        String a = ShiroCryptographyUtil.encryptMD5("123456", "root", 1);

        System.out.println(a);

    }


}
